import axios from 'axios';
import store from '../store/index'


// //自定义配置创建axios的新实例
 const service=axios.create({
    // baseURL:'http://localhost:8888/api/private/v1/',
    // 11111111111111
    baseURL:'api/private/v1/',
    timeout:50000,
    withCredentials: true
 }) 

// 请求拦截器,发起请求,打开loading
service.interceptors.request.use(
  config => {
         if(store.state.token){
            config.headers.Authorization =store.state.token
            config.headers['Content-Type'] = 'application/json;charset=UTF-8' 
            
          }
                return config;
          }, err => {
                return Promise.reject(err)
  
  })
  //响应拦截器,响应回来关闭loading
  service.interceptors.response.use(
    response => {
  return response; 
       }
  , err => {
                  return Promise.reject(err);
  }
  )

 export default service; 